﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UtilZ.Dotnet.Ex.Config;

namespace UtilZ.Tool.WindowsAdapter
{
    [ConfigRoot("WindowsAdapterConfig")]
    public class WindowsAdapterConfig : IConfig
    {

        /// <summary>
        /// 崩溃窗口标题列表
        /// </summary>
        [ConfigCollection("CrushWindowTitles", "WindowTitle", "崩溃窗口标题列表,仅windows系统有效")]
        public List<string> CrushWindowTitles { get; set; }

        ///// <summary>
        ///// 未响应窗口标题后缀
        ///// </summary>
        //[ConfigItem("NoRespondingWindowTitleSuffix", "未响应窗口标题后缀.注意空格和英文版本操作系统,仅windows系统有效")]
        //public string NoRespondingWindowTitleSuffix { get; set; } = " (未响应)";

        /// <summary>
        /// 崩溃窗口尺寸列表
        /// </summary>
        [ConfigCollection("CrushWindowSizeList", "CrushWindowSize", "崩溃窗口尺寸列表",true)]
        public List<CrushWindowSize> CrushWindowSizeList { get; set; }

        /// <summary>
        /// 崩溃窗口尺寸列表示例
        /// </summary>
        [ConfigCollection("CrushWindowSizeListDemo", "CrushWindowSize", "崩溃窗口尺寸列表示例")]
        public List<CrushWindowSize> CrushWindowSizeListDemo { get; set; }

        /// <summary>
        /// 崩溃窗口宽带或高度误差偏移量
        /// </summary>
        [ConfigItem("CrushWindowSizeOffset", "崩溃窗口宽带或高度误差偏移量")]
        public int CrushWindowSizeOffset { get; set; } = 5;

        #region single instance
        private readonly static WindowsAdapterConfig _inctance;
        public static WindowsAdapterConfig Instance
        {
            get { return _inctance; }
        }

        static WindowsAdapterConfig()
        {
            _inctance = ConfigHelper.Load<WindowsAdapterConfig>("WindowsAdapterConfig.xml");
        }
        #endregion




        /// <summary>
        /// 
        /// </summary>
        public WindowsAdapterConfig()
            : base()
        {

        }

        /// <summary>
        /// 
        /// </summary>
        public void InitDefaultValue()
        {
            this.CrushWindowTitles = new List<string>()
            {
                 "Microsoft Visual C++ Runtime Library",
                 " - 应用程序错误",
                 " - application error",
                 "(未响应)",
            };

            this.CrushWindowSizeListDemo = new List<CrushWindowSize>()
            {
                new CrushWindowSize(){Width=451,Height=332 },//win10
                new CrushWindowSize(){Width=451,Height=170 },//win10
                new CrushWindowSize(){Width=482,Height=227 },
                new CrushWindowSize(){Width=451,Height=169 },//win7
                new CrushWindowSize(){Width=451,Height=331 },//win7
            };
        }
    }

    /// <summary>
    /// 崩溃窗口大小
    /// </summary>
    public class CrushWindowSize
    {
        /// <summary>
        /// 崩溃窗口宽度
        /// </summary>
        [ConfigItem("Width", "崩溃窗口宽度")]
        public int Width { get; set; }

        /// <summary>
        /// 崩溃窗口高度
        /// </summary>
        [ConfigItem("Height", "崩溃窗口高度")]
        public int Height { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        public CrushWindowSize()
        {

        }
    }
}
